import 'package:flutter/material.dart';
import 'package:flutterapp/page/home/info/index_data.dart';

//引入组件并传参
import 'item_widget.dart';

class InfoPage extends StatelessWidget {
  final bool showTitle;
  final List<InfoItem> dataList;

  const InfoPage({Key key, this.showTitle = false, this.dataList = infoData})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          //头部第一个
          //用if 或者三元判断是否是首页,是首页就显示头
          if (showTitle)
            Container(
              alignment: Alignment.centerLeft,
              padding: EdgeInsets.all(10.0),
              child: Text(
                '最新资讯',
                style: TextStyle(
                    color: Colors.black,
                    fontWeight: FontWeight.w500,
                    fontSize: 14.0),
              ),
            ),
          //下面的列表
          Column(
            children: dataList.map((e) => ItemWidget(e)).toList(),
          ),
        ],
      ),
    );
  }
}
